#include "synwit_ui_framework/synwit_ui.h"
#include "appkit/screen_id.h"
#include "appkit/screens/open.h"
#include "swm34s/common/lcdc/dev_lcdc.h"
#include "SWM341_sfc.h"
#include "SWM341.h"
static void jump(lv_obj_t* avi,void* user_data)
{
	if(DX_flag)
		synwit_ui_load_screen(SCREEN002);
	else
		synwit_ui_load_screen(SCREEN001);
	logo_flag = false;
}
/*
 * 界面回调函数
 */
static void open_on_timer(void *user_data)
{
    /* 界面定时器回调函数 */
}

static void open_start(synwit_id_t screen_id)
{
    /* 在界面被显示给用户前，这个接口会被调用。 */
		SFC_Read(0x7FF000, SPI_DCache, 3);
		DX_flag = (uint8_t)SPI_DCache[0];
		km_MPH_state =  (uint8_t)SPI_DCache[1];
		Beer_sound_level =  (uint8_t)SPI_DCache[2];
		if(Beer_sound_level==0)
			Beer_sound_level = 1;
		PWM_SetHDuty(PWM1,PWM_CH_A,5000-Beer_sound_level*VOICE_LEVEL);
		printf("SFC_Read-----%d----%d---%d----\r\n",SPI_DCache[0],SPI_DCache[1],SPI_DCache[2]);
    // 打开下面的注释可以为本界面开启一个每100ms触发一次的定时器
    //synwit_ui_start_scr_timer(100, NULL);
		lv_obj_t* avi = synwit_ui_find_lv_obj(WIDGET_AVI_1);
	
		lv_avi_set_on_completed_cb(avi,jump,NULL);
}

static void open_stop(synwit_id_t screen_id)
{
    /* 准备切换到其它界面前，这个接口会被调用。 */
}


/*
 * 界面注册对象
 */
synwit_screen_callback_t open_cb_obj = {
    .on_screen_start = open_start,
    .on_screen_stop = open_stop,
    .on_screen_timer = open_on_timer,
};

